<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
 





function res($code, $msg, $data = [])
{

  return json_encode([
    'err_code' => $code,
    'message' => $msg,
    'data' => $data
  ]);
}

function getPost()
{
  return json_decode(file_get_contents("php://input"), true);
}

function create_token()
{
  return md5(time() . mt_rand(0, 999999999));
}


function getheaders() //定义方法
{
  foreach ($_SERVER as $name => $value) //循环_SERVER数组
  {
    if (substr($name, 0, 5) == 'HTTP_') //前5个字符是HTTP_的进入循环
    {
      $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
      //注释
      //substr($name, 5)，从$name第5个字符向后截取
      //str_replace('_', ' ',)下划线替换成空格
      //strtolower()全部转换为小写
      //ucwords()首字母转换为大写
      //str_replace(' ', '-',)所有空格替换为-
    }
  }
  return $headers; //返回前key前5个字符是HTTP_的数组
  //return $_SERVER; //返回_SERVER数组
}

function myMd5($str){

  return md5(md5($str.'hhhaaa')) ;

}
